package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null;index:ip_idx commit:'账号'"`
	Password string `gorm:"type:varchar(34);not null;index:ip_idx commit:'密码'"`
}
type RealName struct {
	gorm.Model
	UserId   int64  `gorm:"type:varchar(20);not null;index:ip_idx commit:'用户id'"`
	Realname string `gorm:"type:varchar(20);not null;index:ip_idx commit:'真实姓名'"`
	IdCard   string `gorm:"type:char(18);not null;index:ip_idx commit:'身份证号'"`
}

func (u *User) Create() error {
	return DB.Create(&u).Error
}
func (u *User) FindUserInfo(username string) error {
	return DB.Where("username=?", username).Limit(1).Find(&u).Error
}
func (ur *RealName) Create() error {
	return DB.Create(&ur).Error
}
func (ur *RealName) FindRealName(userId int64, idCard string) error {
	return DB.Where("user_id=? or id_card=?", userId, idCard).Find(&ur).Error
}
